package gateway

import (
	"example.com/m/v2/internal/interfaces/dto"
	"example.com/m/v2/internal/interfaces/facade"
	"github.com/gin-gonic/gin"
	"log"
)

func RegisterAccountFacade(gate GateWay, facade *facade.AccountFacade) {
	if gate == nil || facade == nil {
		log.Fatalln("register router fail")
	}

	group := gate.GetHttpEngine().Group("/account")

	{
		group.GET("/queryMainAccount", func(ctx *gin.Context) {
			var args dto.QueryMainAccountDto
			if ctx.ShouldBind(&args) != nil {
				ctx.JSON(200, ParamsCheckErrorResponse())
			}

			accountDto, err := facade.FindMainAccount(ctx, args.Id)
			ctx.JSON(200, ConvertResponse(accountDto, err))
		})
	}
}
